//
//  ViewController.m
//  01-UIViewHomeWork
//
//  Created by QC.L on 16/7/14.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "ViewController.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *backImageV = [[UIImageView alloc] initWithFrame:self.view.frame];
    backImageV.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:backImageV];
    UIImageView *logoV =[[UIImageView alloc] initWithFrame:CGRectMake((WIDTH - 100) / 2, (WIDTH - 100 - 50) / 2 + 20 , 100, 150)];
    logoV.image = [UIImage imageNamed:@"logo_lagou"];
    [self.view addSubview:logoV];
    
   // 用户框
    UIImageView *userImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, logoV.frame.origin.y + logoV.frame.size.height + 40, 40, 40)];
    [userImageV setImage:[UIImage imageNamed:@"icon_username"]];
    userImageV.backgroundColor = [UIColor colorWithRed:31 / 255.0 green:22 / 255.0 blue:19 / 255.0 alpha:1];
    [self.view addSubview:userImageV];
    userImageV.layer.masksToBounds = YES;
    userImageV.layer.cornerRadius = 6;
    
    UIView *shelteView = [[UIView alloc]initWithFrame:CGRectMake(userImageV.frame.origin.x + userImageV.frame.size.width - 5 , userImageV.frame.origin.y, 10, 40)];
    shelteView.backgroundColor = [UIColor colorWithRed:65 / 255.0 green:55 / 255.0 blue:46 / 255.0 alpha:1];
    [self.view addSubview:shelteView];
    
    UITextField *userText = [[UITextField alloc] initWithFrame:CGRectMake(userImageV.frame.origin.x + userImageV.frame.size.width, userImageV.frame.origin.y ,WIDTH - userImageV.frame.origin.x * 2 - userImageV.frame.size.width, 40)];
    userText.backgroundColor = [UIColor colorWithRed:65 / 255.0 green:55 / 255.0 blue:46 / 255.0 alpha:1];
    [self.view addSubview:userText];
    userText.layer.masksToBounds = YES;
    userText.layer.cornerRadius = 6;
  // 密码框
    UIImageView *passWordV = [[UIImageView  alloc] initWithFrame:CGRectMake(userImageV.frame.origin.x, userImageV.frame.origin.y + userImageV.frame.size.height + 1, 40, 40)];
    [self.view addSubview:passWordV];
    [passWordV setImage:[UIImage imageNamed:@"icon_password"]];
    passWordV.backgroundColor = [UIColor colorWithRed:31 / 255.0 green:22 / 255.0 blue:19 / 255.0 alpha:1];
    [self.view addSubview:passWordV];
    passWordV.layer.masksToBounds = YES;
    passWordV.layer.cornerRadius = 6;
  
    UIView *shelteV = [[UIView alloc]initWithFrame:CGRectMake(passWordV.frame.origin.x + passWordV.frame.size.width - 5 , passWordV.frame.origin.y, 10, 40)];
    shelteV.backgroundColor = [UIColor colorWithRed:65 / 255.0 green:55 / 255.0 blue:46 / 255.0 alpha:1];
    [self.view addSubview:shelteV];
    
    UITextField *passWText = [[UITextField alloc] initWithFrame:CGRectMake(passWordV.frame.origin.x + passWordV.frame.size.width, passWordV.frame.origin.y ,WIDTH - passWordV.frame.origin.x * 2 - passWordV.frame.size.width, 40)];
    passWText .backgroundColor = [UIColor colorWithRed:65 / 255.0 green:55 / 255.0 blue:46 / 255.0 alpha:1];
    [self.view addSubview:passWText ];
    passWText.layer.masksToBounds = YES;
   passWText .layer.cornerRadius = 6;
 // 登录按钮
    UIButton *signInButton = [UIButton buttonWithType:UIButtonTypeCustom];
    signInButton.backgroundColor = [UIColor colorWithRed:0 / 255.0 green:174 / 255.0 blue:135 / 255.0 alpha:1];
    [self.view addSubview:signInButton];
    signInButton.frame = CGRectMake(passWordV.frame.origin.x, passWText.frame.origin.y + passWText.frame.size.height + 20, passWordV.frame.size.width + passWText.frame.size.width, 40);
    [self.view addSubview:signInButton];
    [signInButton addTarget:self action:@selector(signButton) forControlEvents:UIControlEventTouchUpInside];
    signInButton.layer.masksToBounds = YES;
    signInButton.layer.cornerRadius = 6;
    [signInButton setTitle:@"登录" forState:UIControlStateNormal];
    [signInButton setTitleColor:[UIColor colorWithRed:17 / 255.0 green:198 / 255.0 blue:168 / 255.0 alpha:1] forState:UIControlStateNormal];
    
    // 忘记密码
    UIButton *fogetP = [UIButton buttonWithType:UIButtonTypeCustom];
    fogetP.frame = CGRectMake(signInButton.frame.origin.x - 10, signInButton.frame.origin.y + signInButton.frame.size.height + 20,100, 30);
    [self.view addSubview:fogetP];
    [fogetP setTitle:@"忘记密码" forState:UIControlStateNormal];
    [fogetP setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [fogetP addTarget:self action:@selector(forgetButton:) forControlEvents:UIControlEventTouchUpInside];
   // 注册
    UIButton *signP = [UIButton buttonWithType:UIButtonTypeCustom];
    signP.frame = CGRectMake(100,fogetP.frame.origin.y + fogetP.frame.size.height + 30 ,WIDTH - 200 , 30);
    [self.view addSubview:signP];
    [signP setTitle:@"现在注册拉勾" forState:UIControlStateNormal];
    [signP setTitleColor:[UIColor colorWithRed:4 / 255.0 green:160 / 255.0 blue:121 / 255.0 alpha:1] forState:UIControlStateNormal];
    [signP addTarget:self action:@selector(signPButton:) forControlEvents:UIControlEventTouchUpInside];
    // 白线
    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(signInButton.frame.origin.x, signP.frame.origin.y + signP.frame.size.height + 20, WIDTH - signInButton.frame.origin.x * 2, 2)];
    whiteView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:whiteView];
   // or
    UILabel *orLabel = [[UILabel alloc] initWithFrame:CGRectMake(whiteView.center.x - 15, whiteView.frame.origin.y - 10, 40, 20)];
    [self.view addSubview:orLabel];
    orLabel.backgroundColor = [UIColor colorWithRed:100 / 255.0 green:72 / 255.0 blue:59 / 255.0 alpha:1];
    orLabel.text = @"or";
    orLabel.textColor = [UIColor whiteColor];
    orLabel.textAlignment = NSTextAlignmentCenter;
    
    //随便逛逛
    UIButton *tripB = [UIButton buttonWithType:UIButtonTypeCustom];
    tripB.frame = CGRectMake((WIDTH - orLabel.frame.size.width) / 2 - 20,orLabel.frame.origin.y + orLabel.frame.size.height + 20,100, 30);
    [self.view addSubview:tripB];
    [tripB setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [tripB addTarget:self action:@selector(tripButton) forControlEvents:UIControlEventTouchUpInside];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)signButton {
    NSLog(@"登录成功");
}


- (void)forgetButton:(UIButton *)button {
    if (button.selected == NO) {
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    } else {
       [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    }
    button.selected = !button.selected;
    NSLog(@"111111");
}

- (void)signPButton:(UIButton *)button {
    if (button.selected == NO) {
        [button setTitleColor:[UIColor colorWithRed:4 / 255.0 green:160 / 255.0 blue:121 / 255.0 alpha:1] forState:UIControlStateNormal];
    } else {
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    button.selected = !button.selected;
    NSLog(@"注册成功");
}

- (void) tripButton {
    NSLog(@"去逛吧!");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
